package com.mvvm.store.ui.into.adaper;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.databinding.DataBindingUtil;
import androidx.recyclerview.widget.RecyclerView;

import com.lihang.nbadapter.BaseAdapter;
import com.mvvm.store.R;
import com.mvvm.store.base.BaseViewHolder;
import com.mvvm.store.bean.basebean.IntoMaterialBean;
import com.mvvm.store.bean.basebean.MaterialInfoBean;
import com.mvvm.store.databinding.ItemMaterialInfoBinding;

public class MaterialInfoAdapter extends BaseAdapter<IntoMaterialBean> {

    @Override
    public RecyclerView.ViewHolder getViewHolder(ViewGroup viewGroup, int viewType) {
        ItemMaterialInfoBinding itemMaterialInfoBinding= DataBindingUtil.inflate(LayoutInflater.from(viewGroup.getContext()), R.layout.item_material_info, viewGroup, false);
        return new BaseViewHolder(itemMaterialInfoBinding);
    }

    @Override
    public void onBindMyViewHolder(RecyclerView.ViewHolder viewHolder, int i) {
        BaseViewHolder baseViewHolder = (BaseViewHolder) viewHolder;
        ItemMaterialInfoBinding itemMaterialInfoBinding=(ItemMaterialInfoBinding) baseViewHolder.binding;
        IntoMaterialBean materialInfoBean=dataList.get(i);
        itemMaterialInfoBinding.tvOddNumber.setText(materialInfoBean.getOddNumber()+"");

        itemMaterialInfoBinding.tvMaterialSnpNumber.setText(materialInfoBean.getSumNumber()+"");

        itemMaterialInfoBinding.tvSumNumber.setText(materialInfoBean.getRealToNumber()+"");

        itemMaterialInfoBinding.tvPackNumber.setText(materialInfoBean.getPackNumber()+"");

        itemMaterialInfoBinding.tvLableNumber.setText(materialInfoBean.getRealToPack()+"");

        if(materialInfoBean.getSumNumber()==materialInfoBean.getRealToNumber()){
            itemMaterialInfoBinding.ivFinishOrder.setVisibility(View.VISIBLE);
        }else {
            itemMaterialInfoBinding.ivFinishOrder.setVisibility(View.GONE);
        }

    }
}
